package com.kefan.reptilemanagement.controller;


import com.kefan.reptilemanagement.common.entities.Application;
import com.kefan.reptilemanagement.common.entities.ResultBody;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sjj
 * @since 2024-05-03
 */
@RestController
@RequestMapping("/application")
public class ApplicationController extends BaseController {
    //新增申请
    @PostMapping("/add")
    public ResultBody add(@RequestBody Application application)
    {
        return ResultBody.success(applicationService.add(application));
    }
    //修改申请
    @PutMapping("/update")
    public ResultBody exchange(@RequestBody Application application)
    {
        return ResultBody.success(applicationService.exchange(application));
    }
    //删除申请
    @DeleteMapping("/delete")
    public ResultBody delete(@RequestParam("id") Long id)
    {
        return ResultBody.success(applicationService.delete(id));
    }
    @GetMapping("/get")
    public ResultBody getApplicationList(@RequestParam(value = "userId",required = false) Long userId,@RequestParam(value = "status",required = false) Integer status,@RequestParam(value = "name",required = false) String name)
    {
        return ResultBody.success(applicationService.getApplicationList(userId,status,name));
    }
    @PutMapping("/accept")
    public ResultBody acceptApplication(@RequestParam("id") Long id)
    {
        return ResultBody.success(applicationService.acceptApplication(id));
    }
    @PutMapping("/cancel")
    public ResultBody cancelApplication(@RequestParam("id") Long id)
    {
        return ResultBody.success(applicationService.cancelApplication(id));
    }

}
